package com.ydgk.dao;

import com.ydgk.bean.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface OrderMapper {
    void insert(Order order);
    List<Order> findAll(Map<String, Object> factorMap);
    int findAllCount(Map<String, Object> factorMap);

    @Select("select * from `order` where oid = #{oid}")
    Order findById(Integer oid);

    @Select("select * from `order` where ad_adid = #{adid} and otype in(1,2)")
    List<Order> findByAdid(Integer adid);

    @Delete("delete from `order` where ad_adid = #{adid}")
    void deleteByAdid(Integer adid);

    @Update("update `order` set otype = #{otype} where oid = #{oid}")
    void updateById(Order order);

    @Select("select count(*) from `order` o,address ad where o.ad_adid = ad.adid and otype = #{param1} and ad.u_uid = #{param2}")
    int findCountByOtype(Integer otype,Integer oid);

    @Delete("delete from `order` where oid = #{oid}")
    void deleteById(Integer oid);

    @Select("select * from `order` where otype = 1 order by otime desc")
    List<Order> findAllSendOrder();
}
